import React,{Component} from 'react';
import ReactDom from 'react-dom';
import {observable,autorun} from './mobx';
let o = observable([]);

autorun(()=>{
  console.log(o.length)
})
o.push('123')


class Person extends Component{
  constructor(props){
    super(props);
    this.state = {
      num: 1
    }
    setTimeout(()=>{
      this.setState({num:4})
    },1000)
  }
 
  handleClick = ()=> {
    this.setState({num: this.state.num + 1})
  }
  componentDidMount(){
    // setTimeout(()=>{
    //   this.setState({num:4})
    // },1000)
  }
  // UNSAFE_componentWillMount(){
  //   // setTimeout(()=>{
  //   //   this.setState({num:4})
  //   // },0)
  // }
  // static getDerivedStateFromProps(nextProps,prevState){
  //   console.log(prevState,nextProps,'derived')
  //   return null;
  // }
  render(){
     return <h1>{this.state.num}</h1>
  }
}

ReactDom.render(
<Person title='111'/>,
document.getElementById('root')
)
